package com.aaa.service.impl;

import com.aaa.entity.PmsProduct;
import com.aaa.entity.PmsProductCategory;
import com.aaa.mapper.ProTypeMapper;
import com.aaa.service.ProTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class ProTypeImpl extends ServiceImpl<ProTypeMapper, PmsProductCategory> implements ProTypeService {

    @Resource
    ProTypeMapper proTypeMapper;

    @Override
    public List<PmsProduct> selectProId(Integer productCategoryId) {

        return proTypeMapper.selectProId(productCategoryId);
    }

    @Override
    public List<Map<String,Object>> typeList() {
        List<Map<String,Object>> typelist=proTypeMapper.typeList();
        for (Map<String,Object> one:typelist) {
            List<Map<String, Object>> mapList = proTypeMapper.selectByTId(
                    Integer.valueOf(one.get("id").toString()));
            for (int i = 0; i < mapList.size(); i++) {
                if (mapList.get(i) != null) {
                    one.put("mapList", mapList);
                }
            }
        }
        return typelist;
    }

    @Override
    public List<Map<String, Object>> selectAdverty() {
        return proTypeMapper.selectAdverty();
    }

    @Override
    public List<Map<String, Object>> proList(Integer id) {
        return proTypeMapper.proList(id);
    }

    @Override
    public List<Map<String, Object>> projectList() {
        return proTypeMapper.selectProject();
    }
}
